<?php
namespace App\Core\View;


use App\Core\App;
use App\Core\View;

abstract class Component extends View
{
    public function execute()
    {
        $view = $this->getView();
        if ($view) {
            $file = 'component/' . $this->classNameToPath(get_class($this)) . $view . '.phtml';
            $viewPaths = App::getInstance()->getViewPaths();
            foreach ($viewPaths as $path) {
                if (file_exists($path . $file)) {
                    $this->render($path . $file);
                    break;
                }
            }
        }
    }
}